/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaboken.tjugoett;
import static javax.swing.JOptionPane.*;
/**
 *
 * @author Bertil
 */
public class Main {
    

    public static void main(String[] args){
        //initiera en stack (kortbunt) en människa och en datorspelare
        Stack deck = new Stack();
        Human you = new Human(deck);
        Computer me = new Computer(deck, you);
        while(true){
            deck.newDeck();
            deck.shuffle();
            you.play();
            String s = "";
                if(you.points() > 21){
                    s = "You lost. \nDie in a fire you fucking failure.";
                }
                else if(you.points() == 21){
                    s = "A winrar is you.";
                }
                else{ // Computer must play
                    me.play();
                    if(me.points() <= 21 && me.points () >= you.points()){
                        s = "You lost. \nSorry, this game doesn't come with an 'An hero' mode for terrible players.";
                    }
                    else{
                        s = "Congratulations. You have avoided failure.";
                    }
                }
            int answer = showConfirmDialog(null, s + "\nDeal again?");
            if(answer != 0){
                break;
            }
        }
    }
}




